﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using Microsoft.Live.ServerControls.VE;

namespace Microsoft.Live.ServerControls.Web
{
    public partial class _Default : Page
    {
        protected void ServerSideZoomIn_Click(object sender, EventArgs e)
        {
            myMap.ZoomIn();
        }

        protected void ServerSideAerial_Click(object sender, EventArgs e)
        {
            myMap.MapStyle = MapStyle.Aerial;
        }

        protected void ServerSideRoad_Click(object sender, EventArgs e)
        {
            myMap.MapStyle = MapStyle.Road;
        }

        // Hybrid map no longer supported
        //protected void ServerSideHybrid_Click(object sender, EventArgs e)
        //{
        //    myMap.MapStyle = MapStyle.Hybrid;
        //}

        protected void ServerSideShaded_Click(object sender, EventArgs e)
        {
            myMap.MapStyle = MapStyle.Shaded;
        }

        protected void ServerSideZoomOut_Click(object sender, EventArgs e)
        {
            myMap.ZoomOut();
        }

        protected void ServerSidePantoLatLong_Click(object sender, EventArgs e)
        {
            myMap.PanToLatLong(new LatLongWithAltitude(40.71187, -74.01249));
        }

        protected void RotateBirdeyeView_Click(object sender, EventArgs e)
        {
            myMap.SetBirdseyeOrientation(Orientation.South);
        }

        protected void IncludeinView_Click(object sender, EventArgs e)
        {
            myMap.IncludePointInView(new LatLongWithAltitude(42.36919, -71.06644));
        }

        protected void MultipleMethods_Click(object sender, EventArgs e)
        {
            myMap.PanToLatLong(new LatLongWithAltitude(40.71187, -74.01249));
            myMap.StartContinuousPan(1,1);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<LatLongWithAltitude> points = new List<LatLongWithAltitude>();
                points.Add(new LatLongWithAltitude(-20, 20));
                points.Add(new LatLongWithAltitude(20, 20));
                points.Add(new LatLongWithAltitude(20, -20));
                points.Add(new LatLongWithAltitude(-20, -20));
                Shape shape1 = new Shape(ShapeType.Polygon, points);
                //shape1.HideIcon();
                shape1.Title = "J test";
                shape1.Description = "once upon a time";
                shape1.MoreInfoURL = "http://www.soulsolutions.com.au";
                myMap.AddShape(shape1);
                //myMap.AddShape(new Shape(ShapeType.Pushpin, new LatLong(10, 10)));
                //myMap.AddShape(new Shape(ShapeType.Pushpin, new LatLong(5, 5)));
            }
        }

        protected void MiniMap_Click(object sender, EventArgs e)
        {
            myMap.MiniMap = !myMap.MiniMap;
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //myMap.SetBirdseyeScene("1004383");
            LatLongWithAltitude objLatLong = new LatLongWithAltitude(47.622, -122.3491);

            myMap.Clear();
            myMap.MapMode = MapMode.Mode2D;
            myMap.MapStyle = MapStyle.Birdseye;
            //Map1.SetBirdseyeScene("3695545");
            //Map1.SetBirdseyeScene("3695056");

            //Map1.PanToLatLong(new LatLong(47.622, -122.3491, 500));
            myMap.SetBirdseyeScene(objLatLong, Orientation.North, 10, null);

        }

        protected void SetSpecificViewPoints_Click(object sender, EventArgs e)
        {
            List<LatLongWithAltitude> locs = new List<LatLongWithAltitude>();
            locs.Add(new LatLongWithAltitude(-27.475, 153.02796));
            locs.Add(new LatLongWithAltitude(-27.46396, 153.00908));
            locs.Add(new LatLongWithAltitude(-27.46891, 153.05062));
            myMap.SetMapView(locs);
        }

        protected void SetSpecificViewRect_Click(object sender, EventArgs e)
        {
            myMap.SetMapView(new LatLongRectangle(new LatLong(-40.66398, 144.5581), new LatLong(-43.43697, 147.94189)));
        }
    }
}